SuperStrict

Framework brl.glmax2d
Import brl.pngloader

Include "types/math.bmx"
Include "types/TCamera.bmx"
Include "types/TVisual.bmx"
Include "types/TTiles.bmx"

Graphics(800,600)

Local imD2:Byte
Local imX%,imXl%,imXsp%


Local myCam2:TCamera=TCamera.Create()
Local myCam:TCamera=TCamera.Create()
Local cCam:TCamera

myCam.setActiveCamera

Local moveSensivity#=4
Local mouseSensivity#=.3
Local zoomSensivity#=2

Local obj:TVisual[6]

obj[0]=TPoint.Create().setPosition(-10,-10)
obj[1]=TOval.Create(10,10).setPosition(-60,-60)
obj[2]=TRect.Create(50,50).setPosition(-150,-100).setAngle(45).Color(255,128,0)
obj[3]=TPoly.Create(0,0,100,100,0,100).setPosition(-200,-50).turn(23).Color(0,128,255)
obj[4]=TText.Create("Hello World!").setPosition(-20,-20).Color(255,128,128)
'obj[5]=TImg.Create("resources/images/farmer_hat_icon.png").setPosition(-100,-200).setAngle(45).setSize(100,100).Blend(ALPHABLEND)

Local tileMapTest:TileMap=TileMap.Create()

Local imH1:Byte
Local imD1:Byte
Local mX#,mY#,mZ%,mZl%,mZSp%
Local indX%=0
Local indY%=0
Local timeMapPaint:Byte=0

Repeat
	cCam=TCamera.getActiveCamera()
	imH1=MouseHit(1)
	imD1=MouseDown(1)
	imD2=MouseDown(2)
	imXl=imX
	imX=MouseX()
	imXsp=imX-imXl
	
	cCam.move(Float(KeyDown(KEY_D)-KeyDown(KEY_A))/cCam.getZoom()*moveSensivity,Float(KeyDown(KEY_S)-KeyDown(KEY_W))/cCam.getZoom()*moveSensivity)
	If (IMd2)
		cCam.turn(-imXsp*mouseSensivity)
	EndIf
	
	mX=MouseX()
	mY=MouseY()
	mZl=mZ
	mZ=MouseZ()
	mZSp=mZ-mZl
	TCamera.pickXY(mX,mY)
	
	If mX>0 And mX<(TileMap.tileSizeW-1)*32
		If mY>0 And mY<(TileMap.tileSizeH-1)*32
			indX=Min(Max((mX+16)/32,0),(TileMap.tileSizeW-1))
			indY=Min(Max((mY+16)/32,0),(TileMap.tileSizeH-1))
			If (imH1)
				timeMapPaint=1-tileMapTest._array[indX,indY]
				tileMapTest._array[indX,indY]=timeMapPaint 
			End If
			If (imD1)
				tileMapTest._array[indX,indY]=timeMapPaint 
			End If 
		EndIf 
	EndIf

	cCam.zoom(((KeyDown(KEY_NUMADD)-KeyDown(KEY_NUMSUBTRACT))+mZSp*3)*.01*cCam.getZoom()*zoomSensivity)
	
	obj[4].setAngle(Sin(MilliSecs()*.1)*360)
	'obj[5].setAngle(Sin(MilliSecs()*.1)*360)
	
	If KeyHit(KEY_SPACE)
		If (TCamera.getActiveCamera()=myCam)
			myCam2.setActiveCamera
		Else
			myCam.setActiveCamera
		End If
	End If
	If KeyHit(KEY_ESCAPE)
		End
	End If
	
	tileMapTest._draw
	SetAlpha 1
	SetBlend ALPHABLEND
	SetColor 255,255,255
	TVisual.render
	SetAlpha 1
	SetBlend SOLIDBLEND
	SetColor 128,255,128
	TCamera.debug
	SetAlpha 1
	SetBlend ALPHABLEND
	SetColor 255,255,255
	
	'DrawText mZ,10,10
	TCamera.render
Forever